package com.java110.fee.smo.impl;

import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.cheque.ChequeDto;
import com.java110.fee.dao.IChequeServiceDao;
import com.java110.intf.fee.IChequeInnerServiseSMO;
import com.java110.po.cheque.ChequePo;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 票据管理
 */
@RestController
public class ChequeInnerServiseSMOImpl  extends BaseServiceSMO implements IChequeInnerServiseSMO {
    @Autowired
    private IChequeServiceDao chequeServiceDaoImpl;
    @Override
    public int saveCheque(@RequestBody  ChequePo ChequePo) {
        int saveFlag = chequeServiceDaoImpl.saveChequeInfo(BeanConvertUtil.beanCovertMap(ChequePo));
        return saveFlag;
    }

    @Override
    public int updateCheque( @RequestBody ChequePo ChequePo) {
        int saveFlag = chequeServiceDaoImpl.updateChequeInfo(BeanConvertUtil.beanCovertMap(ChequePo));
        return saveFlag;
    }

    @Override
    public int deleteCheque( @RequestBody  ChequePo ChequePo) {
        ChequePo.setStatusCd("1");
        int saveFlag = chequeServiceDaoImpl.updateChequeInfo(BeanConvertUtil.beanCovertMap(ChequePo));
        return saveFlag;
    }

    @Override
    public List<ChequeDto> queryCheques( @RequestBody  ChequeDto ChequeDto) {
        //校验是否传了 分页信息

        int page = ChequeDto.getPage();
        if (page != PageDto.DEFAULT_PAGE) {
            ChequeDto.setPage((page - 1) * ChequeDto.getRow());
        }

        List<ChequeDto> ChequeInfos = BeanConvertUtil.covertBeanList(chequeServiceDaoImpl.getChequeInfo(BeanConvertUtil.beanCovertMap(ChequeDto)), ChequeDto.class);

        return ChequeInfos;
    }

    @Override
    public int queryChequesCount(@RequestBody  ChequeDto ChequeDto) {
        return chequeServiceDaoImpl.queryChequeCount(BeanConvertUtil.beanCovertMap(ChequeDto));
    }

}
